CREATE TABLE babel_4489_trim_t1(a NCHAR(50), b NCHAR(20))
GO
INSERT INTO babel_4489_trim_t1 VALUES(N'  abc🙂defghi🙂🙂    ', N'ab🙂 ')
INSERT INTO babel_4489_trim_t1 VALUES(N'  比尔·拉莫斯    ', N'比拉斯 ')
GO

CREATE TABLE babel_4489_trim_t2(a NVARCHAR(50), b NVARCHAR(20))
GO
INSERT INTO babel_4489_trim_t2 VALUES(N'  abc🙂defghi🙂🙂    ', N'ab🙂 ')
GO

CREATE TABLE babel_4489_trim_t3(a CHAR(50), b CHAR(20))
GO
INSERT INTO babel_4489_trim_t3 VALUES('  abcdefghi    ', 'abi ')
GO

CREATE TABLE babel_4489_trim_t4(a VARCHAR(50), b VARCHAR(20))
GO
INSERT INTO babel_4489_trim_t4 VALUES('  abcdefghi    ', 'abi ')
GO

CREATE TABLE babel_4489_trim_t5(a VARBINARY(50), b VARBINARY(50))
GO
INSERT INTO babel_4489_trim_t5 VALUES(0x61626364, 0x6164)
GO

CREATE TABLE babel_4489_trim_chinese_prc_ci_as(a VARCHAR(50) COLLATE CHINESE_PRC_CI_AS, b VARCHAR(20) COLLATE CHINESE_PRC_CI_AS)
GO
INSERT INTO babel_4489_trim_chinese_prc_ci_as VALUES(N'  比尔·拉莫斯    ', N'比拉斯 ')
GO

CREATE TABLE babel_4489_trim_chinese_prc_cs_as(a VARCHAR(50) COLLATE CHINESE_PRC_CS_AS, b VARCHAR(20) COLLATE CHINESE_PRC_CS_AS)
GO
INSERT INTO babel_4489_trim_chinese_prc_cs_as VALUES(N'  比尔·拉莫斯    ', N'比拉斯 ')
GO

CREATE TABLE babel_4489_trim_chinese_prc_ci_ai(a VARCHAR(50) COLLATE CHINESE_PRC_CI_AI, b VARCHAR(20) COLLATE CHINESE_PRC_CI_AI)
GO
INSERT INTO babel_4489_trim_chinese_prc_ci_ai VALUES(N'  比尔·拉莫斯    ', N'比拉斯 ')
GO

CREATE TABLE babel_4489_trim_arabic_ci_as(a VARCHAR(50) COLLATE ARABIC_CI_AS, b VARCHAR(20) COLLATE ARABIC_CI_AS)
GO
INSERT INTO babel_4489_trim_arabic_ci_as VALUES(N'  الله مع المتقين    ', N'ين ')
GO

CREATE TABLE babel_4489_trim_arabic_cs_as(a VARCHAR(50) COLLATE ARABIC_CS_AS, b VARCHAR(20) COLLATE ARABIC_CS_AS)
GO
INSERT INTO babel_4489_trim_arabic_cs_as VALUES(N'  الله مع المتقين    ', N'ين ')
GO

CREATE TABLE babel_4489_trim_arabic_ci_ai(a VARCHAR(50) COLLATE ARABIC_CI_AI, b VARCHAR(20) COLLATE ARABIC_CI_AI)
GO
INSERT INTO babel_4489_trim_arabic_ci_ai VALUES(N'  الله مع المتقين    ', N'ين ')
GO

CREATE TABLE babel_4489_trim_image(a IMAGE)
GO
INSERT INTO babel_4489_trim_image values(CAST ('6F9619FF-8B86-D011-B42D-00C04FC964FF' AS image))
GO

CREATE TABLE babel_4489_trim_text(a TEXT, b NTEXT)
GO
INSERT INTO babel_4489_trim_text VALUES (N'  abc🙂defghi🙂🙂    ', N'  abc🙂defghi🙂🙂    ')
GO

CREATE TYPE dbo.babel_4489_trim_imageUDT FROM image;
GO

CREATE TYPE dbo.babel_4489_trim_varUDT FROM varchar(50);
GO

CREATE TABLE babel_4489_trim_UDT(a dbo.babel_4489_trim_imageUDT, b dbo.babel_4489_trim_varUDT)
GO
INSERT INTO babel_4489_trim_UDT VALUES(CAST('abcdef' as dbo.babel_4489_trim_imageUDT), CAST('abcdef' as dbo.babel_4489_trim_varUDT))
GO

CREATE VIEW babel_4489_trim_dep_view AS
    SELECT ('|' + TRIM(b FROM a) + '|') as result FROM babel_4489_trim_t2
GO

CREATE PROCEDURE babel_4489_trim_dep_proc AS
    SELECT ('|' + TRIM(b FROM a) + '|') as result FROM babel_4489_trim_t2
GO

CREATE FUNCTION babel_4489_trim_dep_func()
RETURNS NVARCHAR(50)
AS
BEGIN
RETURN (SELECT TOP 1 ('|' + TRIM(b FROM a) + '|') FROM babel_4489_trim_t2)
END
GO

CREATE VIEW babel_4489_trim_dep_view_1 AS
    SELECT ('|' + TRIM(a) + '|') as result FROM babel_4489_trim_t1
GO

CREATE VIEW babel_4489_trim_dep_view_2 AS
    SELECT ('|' + TRIM(a) + '|') as result FROM babel_4489_trim_t2
GO

CREATE VIEW babel_4489_trim_dep_view_3 AS
    SELECT ('|' + TRIM(a) + '|') as result FROM babel_4489_trim_t3
GO

CREATE VIEW babel_4489_trim_dep_view_4 AS
    SELECT ('|' + TRIM(a) + '|') as result FROM babel_4489_trim_t4
GO

CREATE VIEW babel_4489_trim_dep_view_5 AS
    SELECT ('|' + TRIM(a) + '|') as result FROM babel_4489_trim_t5
GO

CREATE VIEW babel_4489_trim_dep_view_6 AS
    SELECT ('|' + TRIM(b FROM a) + '|') as result FROM babel_4489_trim_t4
GO

CREATE FUNCTION babel_4489_trim_itvf_func()
RETURNS TABLE
AS
RETURN (SELECT ('|' + TRIM(b FROM a) + '|') as result FROM babel_4489_trim_t2)
GO